package com.travel.api.service.information.impl

import com.travel.api.service.information.MongoCommonService
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.data.mongodb.core.MongoTemplate
import org.springframework.stereotype.Service

/**
 * @ClassName MongoCommonServiceImpl
 * @Author liguangyao
 * @Date 27/8/18 下午9:49
 * @Version 1.0
 */
@Service
class MongoCommonServiceImpl : MongoCommonService {

    @Autowired
    private val mongoTemplate: MongoTemplate? = null

    override fun saveCollection(objects: List<*>) {
        mongoTemplate!!.insertAll(objects)
    }

    override fun selectCollectionByName(cla: Class<*>, name: String): List<*> {
        return mongoTemplate!!.findAll<Any>(cla as Class<Any>, name)
    }

}
